package pl.elka.simulator.gui.swt.painting;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;

import pl.elka.simulator.core.GravityPoint;
import pl.elka.simulator.core.IPaintable;
import pl.elka.simulator.core.Pair;
import pl.elka.simulator.core.Position;
import pl.elka.simulator.core.experiment.NodePath;
import pl.elka.simulator.gui.swt.PositionConverter;

public class GravityPointPainter implements IElementPainter {

	private Color paintingColor = null;
	
	@Override
	public void paint(IPaintable paintable,PaintEvent e) {
		GravityPoint n = (GravityPoint) paintable;		
		GC gc = e.gc;
		
		if(paintingColor==null){
			paintingColor = e.display.getSystemColor(SWT.COLOR_DARK_GREEN);
		}
	    gc.setForeground(paintingColor);	  
		
	    int deltaRX = PositionConverter.convertToScreenW(n.getRadius());
	    int deltaRY = PositionConverter.convertToScreenH(n.getRadius());
	    Pair<Integer, Integer> pos = PositionConverter.convertFromPosition(n.getPosition());
	    int rx = deltaRX;
		int ry = deltaRY;
		for(int i=1;i<10;++i){		
			gc.drawOval(pos.left-rx/2, pos.right - ry/2, rx, ry);		
			rx+=2*deltaRX;
			ry+=2*deltaRY;
		}
							
	}

}
